package com.easy.controller;

import com.easy.bean.Order_detail;
import com.easy.service.Order_detailService;
import com.easy.util.Page;
import com.easy.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("order_detail")
public class Order_detailController {
    @Autowired
    Order_detailService order_detailService;

    @PostMapping
    public Result add(@RequestBody Order_detail order_detail) {
        Object obj = order_detailService.add(order_detail);
        return Result.success(obj);
    }

    @PutMapping
    public Result edit(@RequestBody Order_detail order_detail) {
        Object obj = order_detailService.edit(order_detail);
        return Result.success(obj);
    }

    @DeleteMapping("{detail_id}")
    public Result delete(@PathVariable("detail_id") Integer id) {
        Object obj = order_detailService.del(id);
        return Result.success(obj);
    }

    @GetMapping("{detail_id}")
    public Result one(@PathVariable("detail_id") Integer id) {
        Object obj = order_detailService.one(id);
        return Result.success(obj);
    }

    @GetMapping("all")
    public Result all(Order_detail order_detail) {
        Object obj = order_detailService.all(order_detail);
        return Result.success(obj);
    }
    @GetMapping("page")
    public Result page(Page page, Order_detail order_detail) {
        order_detailService.page(page,order_detail);
        return Result.success(page);
    }
}
